Backup/Restore using PostgreSQL database in Windows
This document contains steps to perform backup and restore operations of aiv Database with PostgreSQL database in Windows platform.
There are 2 ways we can perform this,
Using command prompt
PgAdmin application
1. Using Command prompt
Backup
List of commands used to perform backup and restore operation are marked below,
Open command prompt and go to location of bin folder in pgsql. As shown in figure below:
location: (your_directory)\aiv4\pgsql\bin
aiv4: name of installed aiv in local machine.
Take backup using below command:
pg_dump -U postgres -p 6432 -W -F t aiv > C:/aiv4/backup.tar
postgres: stand for default username.
aiv: stand for default database name.
aiv: is default password.
6432: is port number
Enter postgreSQL password after adding the command, as shown in figure below:
As per 2nd point, the default password of PostgreSQL is AIVHUB. Add password and hit enter button. it will look as figure below:
Check the backup file at the specified location.
Restore backup file
Open command prompt and go to location of bin folder in pgsql. As shown in figure below:
Login to postgreSQL using command:
psql –d [database name] –U [username] -p 6432
Insert Password, hit enter button. it will login into postgres as shown in figure below:
infoNote: Default password: AIVHUB. The password may not be visible while typing in command prompt.
Here 6432 is database port number. if your database port number is different you may change it before executing this command
If credentials are valid you will see screen as shown in figure below:
dangerStep no 5 & 6 is added here to restore backup data in a new database. if you want to backup data in existing database then skip this step.
After login, add command to create database as follows:
Command line:
create database postgre1;
The command prompt will show the CREATE DATABASE alert as shown in figure below:
To see the available list of databases in aiv, user needs to insert command as follows:
command:
\list
Hit enter after adding command. you can see
aiv1
database in the list.
Now press
ctrl + z
and hit enter to logout from postgres.Now, add command to Restore the dump using command as follows:
Command:
pg_restore -h localhost -p 6432 -U user_name --dbname=backup_db_name --verbose (your_directory)\backup_file_name.tar
Example:
pg_restore -h localhost -p 6432 -U postgres --dbname=postgre1 --verbose C:\aiv4\backup.tar
6432: Port number, the default number is 6432, it’s different from the below figure.
postgres: Default username of PostgreSQL
C:/aiv4/backup.tar: backup file location location of the dump file.
postgre1: Database name which is created by user. or existing database name where you want to restore.
By running above command database will be restore and you can see scrpt running in cmd.
infoIf you find error with this command, check file path or user name or port number or uername-password once and try to run again. Make sure database in which you are restoring is available.
2. pgAdmin application
Other way of performing backup and restore in PostgreSQL is by pgAdmin utility. To know more about how to perform backup and restore please go through official documentation of postgres.follow this link..